#ifndef GLSLPROGRAM_H
#define GLSLPROGRAM_H
#include "Troll3D_global.h"
#include <GL/glew.h>
#include "Shader.h"

#include <iostream>
#include <string>
#include <vector>
#include <fstream>

/*! @brief The Program class is used to load 2 shader   */
class TROLL3DSHARED_EXPORT GLSLProgram
{
    public :

    /****************************************************
    /*					Public
    /****************************************************/

        /****************************************************
        /*					Constructors
        /****************************************************/

            /*! @brief Create a new program from 2 Shaders  */
            GLSLProgram(std::string name, Shader * shader1, Shader * shader2 );

            /*! @brief Copy constructor  */
            GLSLProgram(const Shader & );

            /*! @brief Destructor   */
            ~GLSLProgram();

        /****************************************************
        /*					Methods
        /****************************************************/

            int Init();

            /*! \fn Create the program      */
            int CreateProgram();

            /*! @brief Link the program     */
            int LinkProgram();

            /*! @brief Define the Attributes of the programs    */
            void BindAttributesLocation();

            /*! @brief Get back the index of the vertex Attributes in the program   */
            void DefineAttributeLocation(int indiceAttrib, std::string idAttrib);

            /*! Shortcut to glUseProgram */
            void Use();

            /*! @brief Shortcut to BindProgram(0)   */
            void DisableProgram();

        /****************************************************
        /*					Properties
        /****************************************************/

			std::string				m_Name;			/*!< Name of the GLSLProgram					*/
			
			GLuint                  m_GLID;  		/*!< OpenGL ID given by glCreateProgram, used to fetch the program inside OpenGL/GLSL API    */
			std::vector<Shader *>   m_Shaders;  	/*!< Shaders link to the current Program        */
			
		
    /****************************************
    /*              Static
    /****************************************/
	
        /****************************************************
        /*					Properties
        /****************************************************/
		
            static std::vector<GLSLProgram *>	Programs;	/*!< Store all program the User can Use to add different effect to different object in the scene	*/
		
        /****************************************************
        /*					Methods
        /****************************************************/
		
			/*!	@brief Create a new GLSL Program and add it in the Programs vector 	*/
            static GLuint New(std::string name, Shader * shader1, Shader * shader2 );
			
			/*!	@brief Return the Index in the Programs vector of current 	*/
			static GLuint Find(std::string name);
			
			/*!	@brief Use the program with specified GL Id					*/
			static void Use(GLuint programId);
			
			/*!	@brief Unbind the current GLSL programm						*/
			static void Disable();
		

};

#endif
